package com.application.sistercityapplication.model;

import java.util.List;

import com.application.sistercityapplication.dto.UserDto;
import com.roscopeco.ormdroid.Entity;

public class User extends Entity {
	public int id;
	public String username;
	public String firstname;
	public String lastname;
	public String email;
	public String telephone;
	public String role_id;
	public String key;
	public String updated_at;
	
	

	public User() {
		this(null, null, null, null, null, null, null, null);
	}


	public User(String username, String firstname, String lastname,
			String email, String telephone, String role_id, String key,
			String updated_at) {
		this.username = username;
		this.firstname = firstname;
		this.lastname = lastname;
		this.email = email;
		this.telephone = telephone;
		this.role_id = role_id;
		this.key = key;
		this.updated_at = updated_at;
	}

	public void removeAll() {
		List<User> list = query(User.class).executeMulti();
		for (User mag : list) {
			mag.delete();
		}
	}
	public int getPk(){
		List<User> list = null;
		int key = 1;
		list = query(User.class).executeMulti();
		if(list!=null && !list.isEmpty()){
			key = list.size()+1;
		}
		return key;
		
	}
	
	public boolean isNotEmpty(){
		List<User> list = null;
		boolean isNotEmpty = false;
		list = query(User.class).executeMulti();
		if(list!=null && !list.isEmpty()){
			isNotEmpty = true ;
		}
		return isNotEmpty;
	}
	public String getKey(){
		List<User> list = null;
		String key = "";
		list = query(User.class).executeMulti();
		if(list!=null && !list.isEmpty()){
			key = list.get(0).key;
		}
		return key;
	}
}
